﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TemplateWeb.Models.ViewModels.GroupViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <div class="cate_area">
        <div class="bg_nav">
            <a href="<%= Url.Action("Index", "Home") %>">Trang chủ</a> » Giỏ hàng
        </div>
        <div class="bg_760">
            <h4>
                Giỏ hàng</h4>
        </div>
        <div class="clear">
        </div>
        <div class="bg_760_center" style="padding: 10px; width: 738px;">
            <table rules="all" style="width: 100%; border: 1px solid rgb(187, 216, 241);"
                cellpadding="10" cellspacing="10">
                <tbody>
                    <tr style="color: rgb(2, 79, 147); background-color: rgb(239, 249, 255); font-weight: bold;"
                        align="center">
                        <th>
                            Hình ảnh
                        </th>
                        <th style="text-align:left;">
                            Tên sản phẩm
                        </th>
                        <th>
                            Loại sản phẩm
                        </th>
                        <th>
                            Số lượng
                        </th>
                        <th style="width:60px;">
                            Đơn giá
                        </th>
                        <th style="width:60px;">
                            Thành tiền
                        </th>
                        <th>
                            Xóa
                        </th>
                    </tr>
                    <% foreach (var obj in Model.ShoppingCartModel.CartItems)
                       { %>
                    <tr align="center">
                        <td>
                            <img src="../../Content/Images/Items/<%= obj.SanPham.HinhMinhHoa %>" alt="<%= obj.SanPham.TenSanPham %>"
                                style="height: 80px;">
                        </td>
                        <td class="font_blue" align="left">
                            <b><span id="ContentPlaceHolder1_dgShopCart_ProductName_0">
                                <%= obj.SanPham.TenSanPham %></span></b>
                        </td>
                        <td class="font_blue" align="center">
                            <b>
                                <%= obj.SanPham.LoaiSanPham %></b>
                        </td>
                        <td>
                            <script type="text/javascript">
                                function ReCalcOrder(itemid) {
                                    var num = document.getElementsByName("NumItem" + itemid).item(0);
                                    if (!isNaN(num.value) && parseInt(num.value) > 0) {
                                        window.location.href = "../Home/UpdateQuantityToCart?id=" + itemid + "&num=" + num.value;
                                    } else {
                                        window.location.href = "../Home/UpdateQuantityToCart?id=" + itemid + "&num=" + <%= obj.SoLuong %>;
                                    }
                                }
                            </script>
                            <input type="text" name="NumItem<%= obj.IDSanPham %>" value="<%= obj.SoLuong %>"
                                style="width: 15px; font-size: 10px; text-align: center;" maxlength="2" onkeyup='ReCalcOrder(<%= obj.IDSanPham %>);'>
                        </td>
                        <td align="right">
                            <span class="font_price">
                                <%= string.Format("{0:0,0}", obj.SanPham.GiaBan)%>
                                ₫</span>
                        </td>
                        <td align="right">
                            <span class="font_price">
                                <%= string.Format("{0:0,0}", obj.SanPham.GiaBan * obj.SoLuong)%>
                                ₫</span>
                        </td>
                        <td>
                            <a href="<%= Url.Action("RemoveFromCart", "Home", new { id = obj.ID }) %>" title="Remove from cart"
                                class="RemoveLink">
                                <img src="../../../Content/Images/Home/delete.gif" alt="Remove From Cart" border="0" />
                            </a>
                        </td>
                    </tr>
                    <% } %>
                </tbody>
            </table>
            <div id="ContentPlaceHolder1_pnlTotal">
                <div class="clear">
                </div>
                <div style="float: right;" class="total_cart">
                    <p style="margin: 10px">
                        Tổng tiền: <span class="font_price"><b><span id="ContentPlaceHolder1_lblTotal">
                            <%= string.Format("{0:0,0}", Model.ShoppingCartModel.CartTotal) %>
                            ₫</span></b></span></p>
                </div>
                <div class="clear">
                </div>
                <div style="float: right;">
                    <% using (Html.BeginForm("Approve", "Home", FormMethod.Post))
                       { %>
                    <input type="submit" name="sbt" id="sbt" value="Thanh toán" style="background-image: url(../../../Content/Images/Home/bgbutton.jpg);
                        color: #FFFFFF; font-size: 16px; font-weight: bold; border: 1px #DBDBDB solid;
                        height: 30px; cursor: pointer;" />
                    <% } %>
                </div>
                <div class="clear" style="height: 20px">
                </div>
            </div>
        </div>
        <div class="clear">
        </div>
        <div class="bg_760_bt">
        </div>
    </div>
</asp:Content>
